package com.yunhe.rentcars.pro.controller.rent;

import com.yunhe.rentcars.commons.dto.Pageable;
import com.yunhe.rentcars.pro.entity.rent.CarOrder;
import com.yunhe.rentcars.pro.entity.rent.Cars;
import com.yunhe.rentcars.pro.service.car.CarsService;
import com.yunhe.rentcars.pro.service.rent.YuDingCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2017/12/1 0001.
 */
@Controller
@RequestMapping("/yurent")
public class YunDingCarController {

    @Autowired
    private YuDingCarService yuDingCarService;

    @Autowired
    private CarsService carsService;

    @RequestMapping
    public String predeCar(){
        return "rent/YuRent/PredeCar";
    }

    @RequestMapping("/payOrder")
    public String payOrder(Long id,Long carid,String carcode, HttpServletRequest req){
        CarOrder carOrder = yuDingCarService.findYuDingCarOrder(id);
        Cars cars = carsService.findOne(carid, carcode);
        req.setAttribute("carOrder",carOrder);
        req.setAttribute("cars",cars);
        return "rent/YuRent/PayOrder";
    }

    @RequestMapping("/findYuDingCarList")
    @ResponseBody
    public Pageable<CarOrder> findYuDingCarOrderList(Integer offset, Integer limit, String orderid, String mobile){
        Pageable<CarOrder> pageable = yuDingCarService.findYuDingCarOrderList(offset, limit, orderid, mobile);
        return pageable;
    }


}
